/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            inoutOrderManageInfo: {
                inoutOrders: [],
                total: 0,
                records: 1,
                moreCondition: false,
                orderId: '',
                states: [],
                conditions: {
                    personName: '',
                    orderId: '',
                    shopId: vc.getCurrentCommunity().shopId,
                    orderType: '20000',
                    state: '',
                }
            }
        },
        _initMethod: function () {
            $that._listInoutOrders(DEFAULT_PAGE, DEFAULT_ROWS);
            vc.getDict('inout_order', "state", function (_data) {
                $that.inoutOrderManageInfo.states = _data;
            });
        },
        _initEvent: function () {
            vc.on('inoutOrderManage', 'listInoutOrder', function (_param) {
                $that._listInoutOrders(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listInoutOrders(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listInoutOrders: function (_page, _rows) {
                $that.inoutOrderManageInfo.conditions.page = _page;
                $that.inoutOrderManageInfo.conditions.row = _rows;
                var param = {
                    params: $that.inoutOrderManageInfo.conditions
                };
                param.params.orderId = param.params.orderId.trim();
                param.params.personName = param.params.personName.trim();
                //发送get请求
                vc.http.apiGet('/inoutOrder/queryInoutOrder',
                    param,
                    function (json, res) {
                        var _inoutOrderManageInfo = JSON.parse(json);
                        $that.inoutOrderManageInfo.total = _inoutOrderManageInfo.total;
                        $that.inoutOrderManageInfo.records = _inoutOrderManageInfo.records;
                        $that.inoutOrderManageInfo.inoutOrders = _inoutOrderManageInfo.data;
                        vc.emit('pagination', 'init', {
                            total: $that.inoutOrderManageInfo.records,
                            dataCount: $that.inoutOrderManageInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _queryInoutOrderMethod: function () {
                $that._listInoutOrders(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetInoutOrderMethod: function () {
                $that.inoutOrderManageInfo.conditions.personName = "";
                $that.inoutOrderManageInfo.conditions.orderId = "";
                $that.inoutOrderManageInfo.conditions.state = "";
                $that._listInoutOrders(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _toDetail: function (_inoutOrder) {
                vc.jumpToPage('/#/pages/goods/upShopHouseDetail?orderId=' + _inoutOrder.orderId);
            },
            _doOrderIn: function (_inoutOrder) {
                vc.jumpToPage('/#/pages/goods/doOrderDetailOut?orderId=' + _inoutOrder.orderId);
            }
        }
    });
})(window.vc);
